package com.itany.service;


import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import com.codingapi.tx.annotation.TxTransaction;
import com.itany.api.IExamineService;
import com.itany.api.IUserService;
import com.itany.common.Examine;
import com.itany.common.User;
import com.itany.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl implements IUserService{

    @Autowired
    private UserDao userDao;

    @Reference
    private IExamineService examineService;

    @TxTransaction(isStart = true)
    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public void addUser(User user) {
        userDao.insertUser(user);
        Examine examine = new Examine();
        examine.setFlag(1);
        examine.setTitle(user.getJob()+user.getName()+"审核");
        examine.setUserId(user.getId());
        examineService.addExamine(examine);
        System.out.println(1/0);
    }
}
